import Text from "../../common/Text";
import NormalList from "../../common/NormalList";
import SkillList from "../../common/SkillList";
import { context } from "../../common/context";
import Item from "./components/Item";
import SubTitle from "./components/subTitle";

function Index(props) {
  const { name, initMarginH } = props;
  const {
    resume: { content },
  } = context;
  const item = content[name];
  const isShowSubTitle = [
    "certificate",
    "education",
    "internship",
    "project",
    "school",
    "work",
  ];
  return item?.entries?.map((item, index) => {
    if (item.isHidden) return null;
    return (
      <Item key={index} initMarginH={initMarginH}>
        {isShowSubTitle.includes(name) ? (
          <SubTitle item={item} name={name}></SubTitle>
        ) : null}
        <Text
          key={item.description}
          dangerouslySetInnerHTML={{ __html: item.description }}
        ></Text>
        {name === "hobby" || name === "certificate" ? (
          <NormalList item={item} />
        ) : null}

        {name === "skills" ? <SkillList item={item} name="skills" /> : null}
      </Item>
    );
  });
}

export default Index;
